/**
 * 
 */
package com.taobao.wolfwolf.hibernate.service.impl;

import java.util.List;

import org.apache.log4j.Logger;

import com.taobao.wolfwolf.hibernate.dao.CustomerDao;
import com.taobao.wolfwolf.hibernate.pojo.Customer;
import com.taobao.wolfwolf.hibernate.service.CustomerService;
import com.taobao.wolfwolf.web.servler.PrintExpress;

/**
 * @author Tux
 *
 * 创建时间: 2011-5-4 下午06:41:07
 */
public class CustomerServiceImpl extends BaseServiceImpl implements CustomerService {
	
	private static Logger logger = Logger.getLogger(CustomerServiceImpl.class);
	private CustomerDao cdao;
	
	public List<Customer> findAll() {
		try {
			return cdao.findAll();
		} catch(Exception e) {
			e.printStackTrace();
			logger.error(e);
			System.out.println("Error at findAll()");
		}
		return null;
	}

	public Customer findById(int id) {
		try {
			return cdao.findById(id);
		} catch (Exception e) {
			logger.error(e);
			e.printStackTrace();
			System.out.println("Error at findById(int id)");
		}
		return null;
	}

	public List<Customer> findByName(String name) {
		try {
			return cdao.findByName(name);
		}  catch (Exception e) {
			logger.error(e);
			e.printStackTrace();
			System.out.println("Error at findByName(String name)");
		}
		return null;
	}

	public long getTotal()  {
		try {
			return cdao.getTotal();
		}  catch (Exception e) {
			logger.error(e);
			e.printStackTrace();
			System.out.println("Error at getTotal()");
		}
		return -1;
	}

	public List<Customer> paging(int page, int limit)  {
		try {
			return cdao.paging(page, limit);
		}  catch (Exception e) {
			logger.error(e);
			e.printStackTrace();
			System.out.println("Error at paging(int page, int limit)");
		}
		return null;
	}

	public void setCdao(CustomerDao cdao) {
		this.cdao = cdao;
	}

	public CustomerDao getCdao() {
		return cdao;
	}

	public List<Customer> findByPinyin(String abbr) {
		try {
			return cdao.findByPinyin(abbr);
		} catch (Exception e) {
			logger.error(e);
			e.printStackTrace();
			System.out.println("Error at findByPinyin(String abbr)");
		}
		
		return null;
	}
}
